package vip.xiaonuo.smzq.modular.user.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.user.entity.Kyqrqyb;
import vip.xiaonuo.smzq.modular.user.service.IKyqrqybService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


/**
 * 矿业权人企业表
 *
 * @author sqq
 * @since 2024-07-20
 */
@Api(tags = "矿业权人企业表")
@RestController
@RequestMapping("/user/kyqrqyb")
@Validated
public class KyqrqybController {

    @Resource
    private IKyqrqybService iKyqrqybService;

    /**
     * 添加矿业权人企业表
     */
    @ApiOperation("添加矿业权人企业表")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Kyqrqyb kyqrqyb) {
        iKyqrqybService.save(kyqrqyb);
        return CommonResult.ok();
    }

    /**
     * 删除矿业权人企业表
     */
    @ApiOperation("删除矿业权人企业表")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iKyqrqybService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑矿业权人企业表
     */
    @ApiOperation("编辑矿业权人企业表")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Kyqrqyb kyqrqyb) {
        iKyqrqybService.updateById(kyqrqyb);
        return CommonResult.ok();
    }

    /**
     * 矿业权人企业表分页查询
     * @param kqrssgs 矿权人所属公司
     */
    @ApiOperation("矿业权人企业表分页查询")
    @GetMapping("/getPage")
    public CommonResult<Page<Kyqrqyb>> getPage(
           String kqrssgs
    ) {
        return CommonResult.data(iKyqrqybService.getPage(kqrssgs));
    }

    /**
     * 矿业权人企业表分页查询(只查公司名称)
     * @param kqrssgs 矿权人所属公司
     */
    @ApiOperation("矿业权人企业表分页查询(只查公司名称)")
    @GetMapping("/getCompany")
    public CommonResult<List<String>> getCompany(
           String kqrssgs
    ) {
        return CommonResult.data(iKyqrqybService.getCompany(kqrssgs));
    }


    /**
     * 同步矿业权人企业表
     */
     @ApiOperation("同步矿业权人企业表")
     @GetMapping("/synchronizationKyqrqyb")
     public CommonResult<String> synchronizationKyqrqyb() {
         iKyqrqybService.synchronizationKyqrqyb();
         return CommonResult.ok();
     }







}
